{extend name="$base" /}
{block name="resources"}
<style>
.nav-config-block{
	overflow:hidden;
	box-sizing:border-box;
	line-height:30px;
}
.nav-config-title{
	float:left;
	margin-right:10px;
	padding:6px 6px;
}
.nav-config-content{
	float:left;
	margin-top:6px;
}
.nav-config-content label .radio-common{
	margin-bottom: 4px;
}
.table-header{
	width:100%;
    border-top: 1px solid #e6e9f0;
    border-bottom: 1px solid #e6e9f0;
    background: #f5f7fa;
    font-weight: normal;
    font-size: 12px;
	text-align:left;
	box-sizing:border-box;
	padding:6px 6px;
}
.border-line{
	width:99.8%;
    border: 1px solid #e6e9f0;
	border-top:0;
	margin-bottom:10px;
}
.dis-block{
	display:block;
}
.dis-none{
	display:none;
}
.danger{color:red;}
</style>
{/block}
{block name="main"}
<div class="options-btn">
	<button class="btn-common btn-small" onclick="location.href='{:__URL('ADMIN_MAIN/member/addmemberminlevel')}';">添加等级</button>
</div>


<table class="table-class">

	<thead>
		<tr align="center">
			<th align="left"></th>
			<th align="left">等级名称</th>
			<th align="left">升级条件</th>
			<th align="left">折扣率（%）<span class="row-50"></span></th>
			<th align="left">服务费（个 管理银币）</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody></tbody>
</table>
{/block}
{block name="script"}
<script type="text/javascript">
$(function(){
	$("input[name='level_type']").change(function(){
		var val = $("input[name='level_type']:checked").val();
		$.ajax({
			type : "post",
			url : __URL("ADMIN_MAIN/member/setMemberLevelConfig"),
			data : { "type" : val},
			success : function(data) {
				if (data["code"] > 0) {
					location.reload();
					showTip(data['message'],'success');
				}else{
					showTip(data['message'],'error');
				}
			}
		})
	})
})


function LoadingInfo(page_index) {
	var search_text = $("#search_text").val();
	$.ajax({
		type : "post",
		url : __URL("ADMIN_MAIN/member/memberMinlevellist"),
		data : {
			"page_index" : page_index,
			"page_size" :  $("#showNumber").val()
		},
		success : function(data) {
			if (data["data"].length > 0) {
				$(".table-class tbody").empty();
				for (var i = 0; i < data["data"].length; i++) {
					var html = '';
					html += '<tr align="center">';
					html += '<td align="center">'+ data['data'][i]['min_level_id'] +'</td>';
					html += '<td align="left">'+ data["data"][i]["min_level_name"]+'</td>';
					html += '<td align="left">';
					html += '<div>';
					html += '一次性购买' + data['data'][i]['min_rank_point'] +'元，分享同级别：' + data['data'][i]['level'] + '人，级别达到：' + data['data'][i]['level_id'] + '以上' ;
					html += '</div>';
					html += '</td>';

					html += '<td align="left">' + data['data'][i]['min_goods_discount'] * 100 + '<span class="row-50"></span></td>';
					html += '<td align="left">' + data['data'][i]['min_service_rate'] + '<span class="row-50"></span></td>';
					if(data['data'][i]['min_level_id'] == 1){
						html += '<td> <a href="'+__URL('ADMIN_MAIN/member/updatememberminlevel?min_level_id='+ data['data'][i]['min_level_id'])+'">修改</a></td>';
					}else{
						html += '<td><a href="'+__URL('ADMIN_MAIN/member/updatememberminlevel?min_level_id='+ data['data'][i]['min_level_id'])+'">修改</a>&nbsp;&nbsp;&nbsp;<a href="javascript:deleteMember('+data['data'][i]['min_level_id']+');">删除</a></td>';
					}
					html += '</tr>';
					$(".table-class tbody").append(html);
				}
			} else {
				var html = '<tr align="center"><td colspan="100">暂无符合条件的数据记录</td></tr>';
				$(".table-class tbody").html(html);
			}
			initPageData(data["page_count"],data['data'].length,data['total_count']);
			$("#pageNumber").html(pagenumShow(jumpNumber,$("#page_count").val(),{$pageshow}));
		}
	});
}

function deleteMember(level_id){
	$.ajax({
		type : "post",
		url : "{:__URL('ADMIN_MAIN/member/deleteMemberLevel')}",
		data : { 'level_id' : level_id },
		success : function(data) {
			if (data['code'] > 0) {
				showTip(data['message'],'success');
				location.href=__URL("ADMIN_MAIN/member/memberlevellist");
			} else {
				showTip(data['message'],'error');
			}
		}
	});
}
</script>
{/block}
